<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">    
    <title>javaScript</title>
</head>
<body> 
    <input id="first-number" type="number" value="0" placeholder="第一个数字">  
    <input id="second-number" type="number" value="0" placeholder="第二个数字">
    <button id="add-btn"> 加</button>  
    <button id="minus-btn">减</button>   
    <button id="times-btn">乘</button>
    <button id="divide-btn">除</button>
      <p id="result">运算结果</p>

      <script>
          document.getElementById("add-btn").onclick=function(){
           var fisrtNumber=document.getElementById("first-number").value;
           var secondNumber=document.getElementById("second-number").value;
           document.getElementById("result").innerHTML=Number(fisrtNumber)+Number(secondNumber);
        }
        document.getElementById("minus-btn").onclick=function(){
            var fisrtNumber=document.getElementById("first-number").value;
            var secondNumber=document.getElementById("second-number").value;
            document.getElementById("result").innerHTML=Number(fisrtNumber)-Number(secondNumber);
        }
        document.getElementById("times-btn").onclick=function(){
            var fisrtNumber=document.getElementById("first-number").value;
            var secondNumber=document.getElementById("second-number").value;
            document.getElementById("result").innerHTML=Number(fisrtNumber)*Number(secondNumber);

        }
        document.getElementById("divide-btn").onclick=function(){
              var fisrtNumber=document.getElementById("first-number").value;
              var secondNumber=document.getElementById("second-number").value;

              if (secondNumber==0) {
                 console.log("除数不能为0!")
            } else 
                {
                document.getElementById("result").innerHTML=Number(fisrtNumber)/Number(secondNumber);
                
                }
        }
             
       </script> 

</body>
</html>